package tv_megazineplus

class Users {
    
    String name
    String username
    String hashPassword
    String phoneNumber
    String email
    SecretQuestion secretQuestion
    String hashAnswer
    String fbtoken

    static constraints = {
        secretQuestion(blank: false, nullable: true)
        name(blank: false, nullable:false, size:3..70)
        phoneNumber(unique: true, blank: false, nullable:false, size:9..10, matches:"[0-9]+")
        email(blank: false, nullable:false, email: true, unique: true)
        username(unique: true, blank: false, nullable: false, size:4..12, matches:"[a-zA-z0-9_]+",
            validator: { username, user ->
                return username != user.name

            })
        hashAnswer(nullable: false, blank: false)
        hashPassword(nullable: false, blank: false)
        fbtoken(nullable:true, blank: true)
    }
    
    static mapping = {
        version false
        fbtoken type: 'text'
    }
}
